package joshua.web.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import joshua.web.beans.UserThreadBean;
import joshua.web.facade.FacadeContainerImpl;
import joshua.web.facade.IFacadeContainer;
import joshua.web.facade.ILogicFacade;
import joshua.web.utils.MyBeanUtils;

/**
 * Servlet implementation class ThreadDelete
 */
public class ThreadDelete extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ThreadDelete() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		UserThreadBean bean = MyBeanUtils.populateBeanFromReq(request, UserThreadBean.class);
		IFacadeContainer fc = new FacadeContainerImpl();
		ILogicFacade lf = fc.getLogicFacade();
		boolean res = lf.deleteThreadById(bean.getThreadId());
		request.setAttribute("delRes", res);
		RequestDispatcher rd = request.getRequestDispatcher("delthreadres.jsp");
		rd.forward(request, response);
	}

}
